let utils={

}
/*几行一排的时候 使用*/
utils.chunkArray = (data,segment)=>{
	let len = data.length;
	let ret=[];
	for (var i = 0; i <= len-1; i=i+segment) {
		ret.push(data.slice(i,i+segment))
	}
	return ret;
}


/*每段落上下padding  fontHeight/2*/
utils.calcParagraphWith = (data,cols,rows)=>{
	let placeholder='<>';
	for (var i = data.length - 1; i >= 0; i--) {
		data[i]=placeholder+data[i].replace(/\s|<>/g,"");
	}
	let lines=[placeholder],index=0;//第一页 1行占位  显示标题
	for (var i = 0; i <= data.length - 1; i++) {
          let item = data[i];
          let line='';
          for (var j = 0; j <= item.length - 1; j++) {
            index++;
            line+=item.charAt(j);
            if(index===cols||j===(item.length-1)){
              index=0;
              lines.push(line);
              line='';
            }
          }
        }
    return utils.chunkArray(lines,rows);
}

export default utils;
